<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" >
<head th:include="admin/common/resource ::commonHead('首页')" ></head>
<body>
    <div class="container-fluid">
        <div class="toolbar btn-group-sm" role="toolbar" >
            <h6 style="margin-top: 10px;margin-bottom: 20px" > 后台管理系统 / 影视管理  /  部 </h6>
            <div style="margin-bottom: 10px;" >
                <button shiro:hasPermission="video:list" th:onclick="|loadPage('/admin/video/list')|"  type="button" class="btn btn-sm btn-primary"> 剧场列表 </button>
                <button shiro:hasPermission="part:add" th:onclick="|loadPage('/admin/video/section/add',${productId})|"  type="button" class="btn btn-sm btn-success"> 添加部 </button>
            </div>
        </div>
        <table class="table">
            <thead>
            <tr>
                <th scope="col"> ID </th>
                <th scope="col"> 标题 </th>
                <th scope="col"> 描述 </th>
                <th scope="col"> 创建时间 </th>
                <th scope="col"> 状态 </th>
                <th scope="col"> 操作 </th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="section:${list}" >
                <th scope="row" th:text="${section.id}" ></th>
                <td th:text="${section.title}" ></td>
                <td th:text="${section.description}" >  </td>
                <td th:text="${#dates.format(section.createTime,'yyyy-MM-dd HH:mm')}" ></td>
                <td>正常</td>
                <td>
                    <a shiro:hasPermission="part:edit" class="btn-outline-primary" th:href="@{'/admin/video/section/edit?id='+${section.id}}">编辑</a>
                    <!--<a class="btn-outline-primary" th:href="@{'/admin/video/sections?id='+${course.id}}">章节</a>-->
                    <a shiro:hasPermission="part:delete" class="btn-outline-danger" th:href="@{'javascript:destroy('+${section.id}+')'}">删除</a>
                </td>
            </tr>
            </tbody>
        </table>
        <!-- 分页 -->
    </div>
</body>
<div th:include="admin/common/resource ::footerJs"></div>
<script th:src="@{/layui/layui.all.js}"></script>
<script>
    function loadPage(url,id) {
        window.location.href = url+'?productId='+id;
    }
</script>
<script>
    function destroy(id){
        layer.confirm('真的删除这个分类吗?', function(index){
            layer.close(index);
            //向服务端发送删除指令
            $.ajax({
                type:'delete',
                url: "/admin/video/delete",
                data: {
                    id: id
                },
                success: function (data) {
                    console.log(data);
                    if(data.status == 1){
                        layer.msg("成功",function () {
                            window.location.reload();
                        },2000)
                    }else{
                        layer.msg("失败")
                    }
                }
            })
        });
    }
</script>
</html>